<?php
namespace app\index\validate;
use think\Validate;
class User extends Validate
{
	protected $rule =   [
	        'account_number' => 'require|min:6|max:12', 
			'password' => 'require|length:6,12',
			'confirmPassword' => 'require|confirm:password|length:6,12',
			'username' => 'require|min:3|max:8',
			'mailbox' => 'require|email',
			'vercode'=> 'require'
	    ];
	protected $message  =   [
	        'account_number.require' =>'账号不能为空',
			'account_number.min' => '账号最少不能小于6个字符',
			'account_number.max' => '账号最多不能超过12个字符',
			'account_number.unique' => '账号已被注册',
			
			'password.require' =>'密码不能为空',
			'password.length' => '密码最少不能小于6个字符，最多不能超过12个字符',
			
			'confirmPassword.require' =>'确认密码不能为空',
			'confirmPassword.length' => '确认密码最少不能小于6个字符，最多不能超过12个字符',
			'confirmPassword.confirm' => '确认密码与密码不一致',
			
			'username.require' =>'用户名称不能为空',
			'username.min' => '用户名称最少不能小于3个字符',
			'username.max' => '用户名称最多不能超过8个字符',
			'username.unique' => '用户名称已被注册',
			
			'mailbox.require' => '邮箱不能为空',
			'mailbox.email' => 'QQ邮箱格式错误，正确的是：QQ号@qq.com',
			'mailbox.unique' => '邮箱已被注册',
			
			'vercode.require' => '验证码不能为空'
	    ];	
	 public function sceneRegister()
	    {
	    	return $this->only(['account_number','username','mailbox'])
	        	->append('account_number', 'unique:UserTable')
	            ->append('username', 'unique:UserTable')
				->append('mailbox', 'unique:UserTable');
	    }
	public function sceneLogin()
	{
		return $this->only(['account_number','password']);
	}
}